#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2020/6/30 11:38
# @Author : wn 
# @File: Log.py
# @SoftWare: PyCharm
# @Site:
# @Table:
# ｡◕‿◕｡｡◕‿◕｡｡◕‿◕｡
from trade.models import *


class OperationLog():
    @classmethod
    def opt_log(cls, log_dict):
        print('log_dict',log_dict.get('customerid','OMGOMG,HH'))
        Operationlog.objects.using('quantWebDB').create(
            customerid=log_dict.get('customerid', None),
            modular=log_dict.get('modular', None),
            optfunction=log_dict.get('optfunction', None),
            optinfo=log_dict.get('optinfo', None),
            opttime=log_dict.get('opttime',None),
        )

# 装饰器版本，暂未用到
def log_who(*args, **kwargs):
    def outer(func):
        # @wraps(func)
        def inner(self, request, *args, **kwargs):
            if request.method == "POST":
                data = request.POST
            else:
                data = request.GET
            print(data)

            print('函数调用前的逻辑1')
            res = func(self, request, *args, **kwargs)
            print('函数调用后的逻辑2')
            # 写入日志表：

            return res

        return inner

    return outer
